package com.handshake.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.handshake.entity.UsersEntity;
import com.handshake.service.UsersService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;


/**
 * 用户表
 *
 * @author LcLee Tankiland@outlook.com
 * @since 1.0.0 2024-10-09
 */
@RestController
@RequestMapping("/users")
@Tag(name="用户表")
public class UsersController {
    @Autowired
    private UsersService usersService;
    @GetMapping("/findByname")
    public List<UsersEntity> getvolunteer(@RequestParam(name = "username") String username) {
        return usersService.findByName(username);
    }
    //获取用户列表
    @GetMapping("/list")
    public List<UsersEntity> listUsers() {
        return usersService.list();
    }
    //新增用户
    @PostMapping("/add")
    public void addUsers(@RequestBody UsersEntity users) {
            usersService.save(users);
    }
    //更新用户
    @PutMapping("/update")
    public void updateUsers(@RequestBody UsersEntity users) {
            usersService.updateById(users);
    }
    //删除用户
    @DeleteMapping("/{id}")
    public void deleteUsers(@PathVariable Long id) {
            usersService.removeById(id);
    }
    @PostMapping("/login")
    public List<UsersEntity> userlogin(UsersEntity users) {
        return usersService.login(users);
    }
}
